<template>
	<scroll-view scroll-y="true" class="concat-page">
		
		<view class="friends">
			<friendItem v-for="(item,idx) in friends" :key="idx" :item="item"></friendItem>
		</view>
	</scroll-view>
</template>

<script>
export default {
	data(){
		return {
			_nim:null,
			friends:[]
		}
	},
	onShow() {
		const nim=getApp().globalData._nimInstance
		this._nim=nim
		nim.getFriends({
		  done: this.getFriendsDone
		})
	},
	methods:{
		getFriendsDone(error, friends){
			console.log('获取好友列表' + (!error?'成功':'失败'), error, friends);
			if (!error) {
				this._nim.getUsers({
					accounts: friends.map(item => item.account),
					done: this.getUsersDone
				})
			}
		},
		getUsersDone(error, users){
			console.log('获取用户资料数组' + (!error?'成功':'失败'),error, users);
			if (!error) {
				this.friends=users
			}
		}
	}
}
</script>

<style>
</style>
